**************************************************************
**************** Mind the Protest Gap: ***********************
***The Role of Resources in the Face of Economic Hardship ****
**************************************************************
************ Toni Rodon and Marc Guinjoan ********************
**************************************************************
*** PS: Political Science & Politics > Volume 51 > Issue 1 ***
**************************************************************

*Set path here

****************************
********2006****************
****************************

use "ESS3e03_7.dta", clear

*OUTCOMES
recode pbldmn (1=1 "Yes") (2=0 "No") (else=.), gen(part_demon)
recode badge (1=1 "Yes") (2=0 "No") (else=.), gen(part_badge)
recode sgnptit (1=1 "Yes") (2=0 "No") (else=.), gen(part_petition)
recode bctprd (1=1 "Yes") (2=0 "No") (else=.), gen(part_boycott)
recode contplt (1=1 "Yes") (2=0 "No") (else=.), gen(part_contact)
recode wrkprty (1=1 "Yes") (2=0 "No") (else=.), gen(part_party)
recode wrkorg (1=1 "Yes") (2=0 "No") (else=.), gen(part_organisation)

recode vote (1=1 "Voted") (2=0 "Did not vote") (else=.), gen(part_vote)

*EXPLANATORY VARIABLES - women, education, income, age

recode gndr (1=0 "Male") (2=1 "Female") (else=.), gen(gender)
replace agea = . if age==999
recode agea (14/29=1 "Less than 30") (30/44=2 "From 30 to 44") (45/64=3 "From 45 to 64") (65/103=4 "65 and more"), gen(age_r)
recode hinctnt (77/99=.), gen(h_income)
recode hinctnt (1/3=1 "Low-income") (4/12=0 "rest") (77/99=.), gen(h_income_low)
recode h_income (1/3=1 "Low income") (4/7=2 "Medium income") (8/12=3 "High income"), gen(h_incomecat)
recode edulvla (55/99=.), gen(education)
recode edulvla (1/2=0 "Low educ") (3/5=1 "High educ") (55/99=.), gen(edu_high)

recode lrscale (77/99=.), gen(ideol)

*merge
keep part_* gender agea age_r h_income* education edu_high ideol cntry  dweight pspwght pweight polintr clsprty
gen year=2006
save "2006", replace 

****************************
********2008****************
****************************

use "ESS4e04_5.dta", clear

*OUTCOMES

recode pbldmn (1=1 "Yes") (2=0 "No") (else=.), gen(part_demon)
recode badge (1=1 "Yes") (2=0 "No") (else=.), gen(part_badge)
recode sgnptit (1=1 "Yes") (2=0 "No") (else=.), gen(part_petition)
recode bctprd (1=1 "Yes") (2=0 "No") (else=.), gen(part_boycott)
recode contplt (1=1 "Yes") (2=0 "No") (else=.), gen(part_contact)
recode wrkprty (1=1 "Yes") (2=0 "No") (else=.), gen(part_party)
recode wrkorg (1=1 "Yes") (2=0 "No") (else=.), gen(part_organisation)

recode vote (1=1 "Voted") (2=0 "Did not vote")(else=.), gen(part_vote)

*EXPLANATORY VARIABLES - women, education, income, age

recode gndr (1=0 "Male") (2=1 "Female") (else=.), gen(gender)
replace agea = . if agea>121
recode agea (14/29=1 "Less than 30") (30/44=2 "From 30 to 44") (45/64=3 "From 45 to 64") (65/105=4 "65 and more"), gen(age_r)
recode hinctnt (77/99=.), gen(h_income)
recode hinctnt (1/3=1 "Low-income") (4/12=0 "rest") (77/99=.), gen(h_income_low)
recode h_income (1/3=1 "Low income") (4/7=2 "Medium income") (8/10=3 "High income"), gen(h_incomecat)
recode edulvla (55/99=.), gen(education)
recode edulvla (1/2=0 "Low educ") (3/5=1 "High educ") (55/99=.), gen(edu_high)

recode lrscale (77/99=.), gen(ideol)

*merge
keep part_* gender agea age_r h_income* education edu_high ideol cntry  dweight pspwght pweight polintr clsprty
gen year=2008
save "2008", replace 

****************************
********2010****************
****************************

use "ESS5e03_4.dta", clear

*OUTCOMES

recode pbldmn (1=1 "Yes") (2=0 "No") (else=.), gen(part_demon)
recode badge (1=1 "Yes") (2=0 "No") (else=.), gen(part_badge)
recode sgnptit (1=1 "Yes") (2=0 "No") (else=.), gen(part_petition)
recode bctprd (1=1 "Yes") (2=0 "No") (else=.), gen(part_boycott)
recode contplt (1=1 "Yes") (2=0 "No") (else=.), gen(part_contact)
recode wrkprty (1=1 "Yes") (2=0 "No") (else=.), gen(part_party)
recode wrkorg (1=1 "Yes") (2=0 "No") (else=.), gen(part_organisation)

recode vote (1=1 "Voted") (2=0 "Did not vote")(else=.), gen(part_vote)

*EXPLANATORY VARIABLES - women, education, income, age

recode gndr (1=0 "Male") (2=1 "Female") (else=.), gen(gender)
replace agea = . if agea==999
recode agea (14/29=1 "Less than 30") (30/44=2 "From 30 to 44") (45/64=3 "From 45 to 64") (65/103=4 "65 and more"), gen(age_r)
recode hinctnt (77/99=.), gen(h_income)
recode hinctnt (1/3=1 "Low-income") (4/12=0 "rest") (77/99=.), gen(h_income_low)
recode h_income (1/3=1 "Low income") (4/7=2 "Medium income") (8/12=3 "High income"), gen(h_incomecat)

*New coding for education. Equivalence here: https://www.europeansocialsurvey.org/docs/round6/survey/ESS6_appendix_a1_e02_0.pdf
recode edulvlb (5555/9999=.), gen(education)
recode edulvlb (0/229=0 "Low educ") (311/800=1 "High educ") (else=.), gen(edu_high)

recode lrscale (77/99=.), gen(ideol)

*merge
keep part_* gender agea age_r h_income* education edu_high ideol cntry  dweight pspwght pweight polintr clsprty
gen year=2010
save "2010", replace 

****************************
********2012****************
****************************

use "ESS6e02_4.dta", clear

*OUTCOMES

recode pbldmn (1=1 "Yes") (2=0 "No") (else=.), gen(part_demon)
recode badge (1=1 "Yes") (2=0 "No") (else=.), gen(part_badge)
recode sgnptit (1=1 "Yes") (2=0 "No") (else=.), gen(part_petition)
recode bctprd (1=1 "Yes") (2=0 "No") (else=.), gen(part_boycott)
recode contplt (1=1 "Yes") (2=0 "No") (else=.), gen(part_contact)
recode wrkprty (1=1 "Yes") (2=0 "No") (else=.), gen(part_party)
recode wrkorg (1=1 "Yes") (2=0 "No") (else=.), gen(part_organisation)

recode vote (1=1 "Voted") (2=0 "Did not vote")(else=.), gen(part_vote)

*EXPLANATORY VARIABLES - women, education, income, age

recode gndr (1=0 "Male") (2=1 "Female") (else=.), gen(gender)
replace agea = . if agea==999
recode agea (14/29=1 "Less than 30") (30/44=2 "From 30 to 44") (45/64=3 "From 45 to 64") (65/103=4 "65 and more"), gen(age_r)
recode hinctnt (77/99=.), gen(h_income)
recode hinctnt (1/3=1 "Low-income") (4/12=0 "rest") (77/99=.), gen(h_income_low)
recode h_income (1/3=1 "Low income") (4/7=2 "Medium income") (8/12=3 "High income"), gen(h_incomecat)

*New coding for education. Equivalence here: https://www.europeansocialsurvey.org/docs/round6/survey/ESS6_appendix_a1_e02_0.pdf
recode edulvlb (5555/9999=.), gen(education)
recode edulvlb (0/229=0 "Low educ") (311/800=1 "High educ") (else=.), gen(edu_high)

recode lrscale (77/99=.), gen(ideol)

*merge
keep part_* gender agea age_r h_income* education edu_high ideol cntry  dweight pspwght pweight polintr clsprty
gen year=2012
save "2012", replace 

****************************
********2014****************
****************************

use "ESS7e02_2.dta", clear

*OUTCOMES

recode pbldmn (1=1 "Yes") (2=0 "No") (else=.), gen(part_demon)
recode badge (1=1 "Yes") (2=0 "No") (else=.), gen(part_badge)
recode sgnptit (1=1 "Yes") (2=0 "No") (else=.), gen(part_petition)
recode bctprd (1=1 "Yes") (2=0 "No") (else=.), gen(part_boycott)
recode contplt (1=1 "Yes") (2=0 "No") (else=.), gen(part_contact)
recode wrkprty (1=1 "Yes") (2=0 "No") (else=.), gen(part_party)
recode wrkorg (1=1 "Yes") (2=0 "No") (else=.), gen(part_organisation)

recode vote (1=1 "Voted") (2=0 "Did not vote")(else=.), gen(part_vote)

*EXPLANATORY VARIABLES - women, education, income, age

recode gndr (1=0 "Male") (2=1 "Female") (else=.), gen(gender)
replace agea = . if agea>104
recode agea (14/29=1 "Less than 30") (30/44=2 "From 30 to 44") (45/64=3 "From 45 to 64") (65/104=4 "65 and more"), gen(age_r)
recode hinctnt (77/99=.), gen(h_income)
recode hinctnt (1/3=1 "Low-income") (4/12=0 "rest") (77/99=.), gen(h_income_low)
recode h_income (1/3=1 "Low income") (4/7=2 "Medium income") (8/12=3 "High income"), gen(h_incomecat)

*New coding for education. Equivalence here: https://www.europeansocialsurvey.org/docs/round6/survey/ESS6_appendix_a1_e02_0.pdf
recode edulvlb (5555/9999=.), gen(education)
recode edulvlb (0/229=0 "Low educ") (311/800=1 "High educ") (else=.), gen(edu_high)

recode lrscale (77/99=.), gen(ideol)

*merge
keep part_* gender agea age_r h_income* education edu_high ideol cntry  dweight pspwght pweight polintr clsprty
gen year=2014
save "2014", replace 

***************************
*** Economic factors ******
***************************

**** GDP ***

import excel using "gdpchange.xls",  first cellrange(A10:M50) clear
reshape long year, i(country)
rename year gdp_base2010
rename _j year

encode country, gen(c_num)

tsset c_num year
gen gdpchange= gdp_base2010 - (l.gdp_base2010)

drop if year==2004

save "gdpchange", replace

**** UNEMPLOYMENT ****

import excel "unemployment.xls", cellrange(a1:v29) first clear
drop year199* year2000 year2001 year2002 year2003
reshape long year, i(country)
rename year unemployment
rename _j year

save "unemployment", replace

**** GDP PER CAPITA **

import excel "gdpcapita.xls", cellrange(a10:k50) first clear
reshape long year, i(country)
rename year gdpcapita
rename _j year

save "gdpcapita", replace

*** Merge ****
use "gdpchange", clear
merge 1:1 country year using "gdpcapita"
drop _merge
merge 1:1 country year using "unemployment"
drop _merge 

save "mergeeconomy", replace


*************************************
*** Final merge *********************
*************************************

use "2006", clear
append using "2008"
append using "2010"
append using "2012"
append using "2014"

gen country=""
replace country="Albania" if cntry=="AL"
replace country="Austria" if cntry=="AT"
replace country="Belgium" if cntry=="BE"
replace country="Bulgaria" if cntry=="BG"
replace country="Switzerland" if cntry=="CH"
replace country="Cyprus" if cntry=="CY"
replace country="Czech Republic" if cntry=="CZ"
replace country="Germany" if cntry=="DE"
replace country="Denmark" if cntry=="DK"
replace country="Estonia" if cntry=="EE"
replace country="Spain" if cntry=="ES"
replace country="Finland" if cntry=="FI"
replace country="France" if cntry=="FR"
replace country="United Kingdom" if cntry=="GB"
replace country="Greece" if cntry=="GR"
replace country="Croatia" if cntry=="HR"
replace country="Hungary" if cntry=="HU"
replace country="Ireland" if cntry=="IE"
replace country="Israel" if cntry=="IL"
replace country="Iceland" if cntry=="IS"
replace country="Italy" if cntry=="IT"
replace country="Lithuania" if cntry=="LT"
replace country="Latvia" if cntry=="LV"
replace country="Netherlands" if cntry=="NL"
replace country="Norway" if cntry=="NO"
replace country="Poland" if cntry=="PL"
replace country="Portugal" if cntry=="PT"
replace country="Romania" if cntry=="RO"
replace country="Russian Federation" if cntry=="RU"
replace country="Sweden" if cntry=="SE"
replace country="Slovenia" if cntry=="SI"
replace country="Slovakia" if cntry=="SK"
replace country="Turkey" if cntry=="TR"
replace country="Ukraine" if cntry=="UA"
replace country="Kosovo" if cntry=="XK"

***New variables

*index participation
alpha part_demon part_petition part_boycott, gen(part_index)

*high cost participation: part_demon

*low cost participation
alpha part_petition part_boycott, gen(part_low)
recode part_low (0.5=1), gen(part_low2)

*year dummies
tab year, gen(year_)
rename year_1 Year2006
rename year_2 Year2008
rename year_3 Year2010
rename year_4 Year2012
rename year_5 Year2014

*LR scale categorical
recode ideol (0/2=1 "Extreme left") (3/4=2 "Left") (5=3 "Center") (6/7=4 "Right") (8/10=5 "Extreme right"), gen(ideol5)

* other controls
recode polintr (1=4 "Very interested ") (2=3 "Quite intetested") (3=2 "Hardly interested") (4=1 "Not interested at all") (7/9=.), gen(pol_interest)
recode clsprty (1=1 "Yes") (2=0 "No") (7/9=.), gen(close_party)

***final merge
merge m:1 country year using "mergeeconomy"
drop if _merge<3

save mergeall, replace
